package com.xxjqr.rbac.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;

/**
 * @描述  消息编码枚举类;具体业务的枚举应该继承自该枚举做拓展
 * @码农 丁昌江
 * @日期 2021/1/31 22:11
 */
@AllArgsConstructor//全参构造
@Getter
public enum CodeMsgEnum implements BaseEnum{

    //返回正确枚举
    SUCESS(200,"成功"),

    //通用异常
    SERVER_ERROR(500,"服务端异常"),

    REQUEST_NOTFOUND(404,"请求异常"),
    NOTFOUND(405,"找不到当前信息"),
    ADD_ERROR(406,"数据添加失败"),
    VALIDATE_ERROR(407,"参数校验异常"),

    AUTH_FAIL(601,"无权访问"),
    LOGIN_FIRST(602,"请先登录"),
    CAPTCHA_FAIL(603, "验证码错误"),
    CAPTCHA_EXPIRE(604, "验证码过期"),
    USER_NOTFOUND(605, "用户名不存在"),
    PASSWORD_ERROR(606, "密码错误");


    // 错误消息码
    @EnumValue
    @JsonValue
    private final Integer code;
    // 错误消息提示
    private String msg;


    //public void setCode(int code) {
    //    this.code = code;
    //}
    //
    //public String getMsg() {
    //    return msg;
    //}
    //
    public void setMsg(String msg) {
        this.msg = msg;
    }

    @Override
    public String getName() {
        return name();
    }
}
